package com.example.myapplication.activity;

import android.view.View;
import android.widget.EditText;
import android.widget.TextView;

import com.example.myapplication.BaseActivity;
import com.example.myapplication.R;
import com.example.myapplication.event.ChangeNameEvent;
import com.example.myapplication.util.ToastUtil;

import org.greenrobot.eventbus.EventBus;

public class ChangeNameAty extends BaseActivity {
    private TextView tvTitle;
    private EditText etName;
    private View btSave;
    @Override
    protected void logicStart() {
        tvTitle.setText("修改昵称");
    }

    @Override
    protected void initView() {
        tvTitle=findViewById(R.id.tvTitle);
        etName=findViewById(R.id.etName);
        btSave=findViewById(R.id.btSave);

    }

    @Override
    protected void setListener() {
        super.setListener();

        btSave.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (etName.getText().toString().isEmpty()){
                    ToastUtil.toast("请填写您要更改的昵称哦~");
                    return;
                }
                EventBus.getDefault().post(new ChangeNameEvent(etName.getText().toString()));
                finish();
            }
        });
    }

    @Override
    public int getLayoutId() {
        return R.layout.aty_changename;
    }
}
